#pragma once

#include "fontclass.h"
#include "fontshaderclass.h"
#include <vector>

/// <Summary>
/// Class name: TextClass: Handles all the 2D text drawing that the application will need.
///	It renders 2D text to the screen and uses the FontClass and FontShaderClass to assist it.
/// </Summary>

class TextClass
{
private:
	struct SentenceType	// Holds the rendering information for each text sentance.
	{
		ID3D11Buffer	*vertexBuffer, *indexBuffer;			// Sentence vertex and index buffer.
		int				vertexCount, indexCount, maxLength;		// Sentence data members.
		float			red, green, blue;						// Text colour RGB.
	};
	
	struct VertexType			// Vertex structure must match the one in the FontClass.
	{
		D3DXVECTOR3 position;	// Position of vertex on the screen.
		D3DXVECTOR2 texture;	// Texture coordinates of vertex.
	};

public:
	TextClass();
	TextClass(const TextClass& rhs);
	~TextClass();

	bool Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, HWND hwnd, 
		int screenWidth, int screenHeight, D3DXMATRIX baseViewMatrix);
	void Shutdown();
	bool Render(ID3D11DeviceContext* deviceContext, D3DXMATRIX orthoMatrix);

	bool SetMousePosition(int mouseX, int mouseY,  ID3D11DeviceContext* deviceContext);
	bool SetCommandLine(std::vector<char>& inputb, ID3D11DeviceContext* deviceContext);

private:
	bool InitializeSentence(SentenceType** sentence, int maxLength, ID3D11Device* device);
	bool UpdateSentence(SentenceType* sentence, char* text, int positionX, int positionY, float red, 
		float green, float blue, ID3D11DeviceContext* deviceContext);
	void ReleaseSentence(SentenceType** sentence);
	bool RenderSentence(ID3D11DeviceContext* deviceContext, SentenceType* sentence, D3DXMATRIX worldMatrix, 
		D3DXMATRIX orthoMatrix);

private:
	FontClass*			m_Font;
	FontShaderClass*	m_FontShader;
	int					m_screenWidth, m_screenHeight;
	D3DXMATRIX			m_baseViewMatrix;

	// We will use two sentances in this sample application.
	SentenceType*		m_sentence1;
	SentenceType*		m_sentence2;
	SentenceType*		m_command;
};